package com.nunbey.lingxi.controller;


import com.nunbey.lingxi.mode.useraccount.UserAccountEntity;
import com.nunbey.lingxi.mode.useraccount.UserSignDTO;
import com.nunbey.lingxi.service.UserAccountService;
import common.webresult.WebResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author lincat
 */
@Tag(name = "userAccount", description = "用户账户接口")
@RequestMapping("/userAccount")
@RestController
@CrossOrigin
public class UserAccountController {
    @Autowired
    UserAccountService userService;

    @GetMapping("/checkUserEmail/{email}")
    @Operation(summary = "用户邮箱验证")
    public WebResult checkUserEmail(@PathVariable String email){
        return userService.checkUserEmail(email);
    }


    /**
     * 用户注册
     * @param userSign
     * @return
     */
    @PostMapping("/sign")
    @Operation(summary = "用户注册")
    public WebResult userSign(@RequestBody UserSignDTO userSign) throws Exception {
        return userService.userSign(userSign);
    }

    /**
     * 用户登录
     * @param user
     * @return
     * @throws Exception
     */
    @PostMapping("/login")
    @Operation(summary = "用户登录")
    public WebResult userLogin(@RequestBody UserAccountEntity user) throws Exception {
        return userService.userLogin(user);
    }

}
